import React from 'react';
import {createBottomTabNavigator} from 'react-navigation';
import createStackNavigator from "react-navigation/src/navigators/createStackNavigator";
import TabBarItem from './TabBarItem';
import HomeScreen from './Home';
import FindScreen from './Find';
import MessageScreen from './Message';
import MineScreen from './Mine';
import DetailScreen from './Detail';


/**
 * 主页 栈
 */
const HomeStack = createStackNavigator({
	Home: HomeScreen,
	Detail: DetailScreen,
});

/**
 * 发现栈
 */
const FindStack = createStackNavigator({
	Find: FindScreen,
	Detail: DetailScreen
});

/**
 * 消息 栈
 */
const MessageStack = createStackNavigator({
	Message: MessageScreen,
	Detail: DetailScreen
});

/**
 * 我的 栈
 */
const MineStack = createStackNavigator({
	Mine: MineScreen,
	Detail: DetailScreen
});

/**
 * 底部导航器
 * 官网 https://reactnavigation.org/docs/en/getting-started.html
 */
const BottomTabNavigator = createBottomTabNavigator(
	{
		Home: HomeStack,
		Find: FindStack,
		Message: MessageStack,
		Mine: MineStack
	},
	{
		navigationOptions: ({navigation}) => ({
			tabBarIcon: ({focused, tintColor}) => {
				const {routeName} = navigation.state;
				switch (routeName) {
					case 'Home':
						return (
							<TabBarItem
								tintColor={tintColor}
								focused={focused}
								normalImage={require('./../../../img/tab_home.png')}
								selectedImage={require('./../../../img/tab_home_press.png')}
							/>
						);
					case 'Find':
						return (
							<TabBarItem
								tintColor={tintColor}
								focused={focused}
								normalImage={require('./../../../img/tab_find.png')}
								selectedImage={require('./../../../img/tab_find_press.png')}
							/>
						);
					case 'Message':
						return (
							<TabBarItem
								tintColor={tintColor}
								focused={focused}
								normalImage={require('./../../../img/tab_message.png')}
								selectedImage={require('./../../../img/tab_message_press.png')}
							/>
						);
					case 'Mine':
						return (
							<TabBarItem
								tintColor={tintColor}
								focused={focused}
								normalImage={require('./../../../img/tab_mine.png')}
								selectedImage={require('./../../../img/tab_mine_press.png')}
							/>
						);
				}
			},
			tabBarOptions: {
				activeTintColor: 'tomato',
				inactiveTintColor: 'gray'
			}
		})
	}
);


/**
 * 导出当前Module
 */
module.exports = BottomTabNavigator;